<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:comps="http://java.sun.com/jsf/composite/components">

<h:panelGrid columns="3" columnClasses="topAlign, topAlign, topAlign">

	<h:form id="pesquisaBlogForm">

		<p:panel styleClass="panelCrudEsquerda"
			header="#{locale['crud.pesquisa.titulo']}">

			<h:panelGrid id="grid" columns="2">

				<p:outputLabel id="nomePesquisaLbl" for="nomePesquisa"
					value="#{locale['blog.label.nome']}:" />
				<p:inputText id="nomePesquisa"
					value="#{AdminBlogBean.nomePesquisa}" size="25" tabindex="1" />

				<p:outputLabel id="tituloPesquisaLbl" for="tituloPesquisa" 
					value="#{locale['blog.label.titulo']}:" />
				<p:inputText id="tituloPesquisa"													
					value="#{AdminBlogBean.tituloPesquisa}" size="25" tabindex="2" />

				<p:outputLabel id="descricaoPesquisaLbl" for="descricaoPesquisa"
					value="#{locale['blog.label.descricao']}:" />
				<p:inputText id="descricaoPesquisa"													
					value="#{AdminBlogBean.descricaoPesquisa}" size="25" tabindex="3" />											

				<p:outputLabel id="assuntosPesquisaLbl" for="assuntosPesquisa"
					value="#{locale['blog.label.assuntos']}:" />
				<p:inputText id="assuntosPesquisa"													
					value="#{AdminBlogBean.assuntosPesquisa}" size="25" tabindex="3" />	
		
			</h:panelGrid>
		
			<f:facet name="footer">
			
				<h:panelGroup layout="block" style="text-align: right;">
				
					<p:commandButton styleClass="ui-priority-primary"
						update=":tabView:listagemBlogForm:registros"
						value="#{locale['crud.pesquisa.botao.pesquisar']}"
						icon="ui-icon-search" action="#{AdminBlogBean.pesquisar()}"
						tabindex="5">
					</p:commandButton>				
				
					<p:commandButton
						update=":tabView:pesquisaBlogForm, :tabView:listagemBlogForm:registros"
						value="#{locale['crud.pesquisa.botao.limpar']}"
						icon="ui-icon-cancel" action="#{AdminBlogBean.limparFormPesquisa()}"
						tabindex="6">
					</p:commandButton>				
				
				</h:panelGroup>			
					
			</f:facet>
				
		</p:panel>
		
	</h:form>
	
	<p:spacer style="width: 10px" />
						
	<p:panel header="#{locale['blog.tituloGrid']}">
	
		<h:form id="listagemBlogForm">
		
			<h:panelGroup layout="block" style="width: 935px;">
					
				<p:dataTable id="registros" var="registro"
					styleClass="dataTableListagem"
					widgetVar="blogTable"
					value="#{AdminBlogBean.blogs}"
					paginator="true" rows="12"
					paginatorPosition="bottom"
					paginatorAlwaysVisible="true"
					tableStyleClass="tableListagem"
					emptyMessage="#{locale['crud.pesquisa.lista.semResultado']}">
													
					<p:column sortBy="#{registro.codigo}">
									
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" value="Cod" />
						</f:facet>
						<h:outputText value="#{registro.codigo}" />
					
					</p:column>
					
					<p:column sortBy="#{registro.nome}">
									
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['blog.label.nome']}" />
						</f:facet>
						<h:panelGroup layout="block" style="width: 200px;">
							<h:outputText value="#{registro.nome}" />
						</h:panelGroup>
					
					</p:column>
					
					<p:column sortBy="#{registro.titulo}">
									
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['blog.label.titulo']}" />
						</f:facet>
						<h:panelGroup layout="block">
							<h:outputText value="#{registro.titulo}" />
						</h:panelGroup>
					
					</p:column>										
			
					<p:column sortBy="#{registro.descricao}">
									
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['blog.label.descricao']}" />
						</f:facet>
						<h:panelGroup layout="block">
							<h:outputText value="#{registro.descricao}" />
						</h:panelGroup>
					
					</p:column>
											
					<p:column sortBy="#{registro.assuntos}">
							
						<f:facet name="header">
							<h:outputText value="#{locale['blog.label.assuntos']}"  />
						</f:facet>
						<h:panelGroup layout="block">
							<h:outputText value="#{registro.assuntos}" />
						</h:panelGroup>
										
					</p:column>
					
					<p:column sortBy="#{registro.dono.nome}">
							
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;"
								value="#{locale['blog.label.dono']}"  />
						</f:facet>
						<h:panelGroup layout="block">
							<h:outputText value="#{registro.dono.nome}" />
						</h:panelGroup>
										
					</p:column>							
									
					<p:column styleClass="alignCenter">
								
						<f:facet name="header">
							<h:outputText value="#{locale['crud.pesquisa.lista.acoes']}"
								styleClass="dataTableTextoColunaCabecalho" />
						</f:facet>
						
						<h:panelGroup layout="block" style="width: 70px;">
			
							<p:commandButton icon="ui-icon-pencil"
								title="#{locale['crud.botao.editar']}"
								action="#{AdminBlogBean.prepararEdicao(registro)}"
								update=":tabView:edicaoBlogForm"
								oncomplete="edicaoBlogDlg.show()" />
							
							<p:spacer width="5" />
										
							<p:commandButton icon="ui-icon-trash"
								title="#{locale['crud.botao.excluir']}"
								action="#{AdminBlogBean.prepararExclusao(registro)}" />						
											
						</h:panelGroup>
											
					</p:column>
														
				</p:dataTable>
			
			</h:panelGroup>
							
		</h:form>	
			
	</p:panel>
			
</h:panelGrid>		
		
<p:dialog appendToBody="true"
	widgetVar="edicaoBlogDlg"
	modal="true" showEffect="fade" hideEffect="fade"
	resizable="false" draggable="false" closable="false">
	
	<f:facet name="header">
		<h:outputFormat value="#{locale['edicao.titulo']}">
			<f:param value="#{locale['blog']}" />
		</h:outputFormat>
	</f:facet>
	
	<h:form id="edicaoBlogForm">
	
		<h:panelGroup layout="block">
			<p:messages id="insercaoBlogMsg" closable="true" />
		</h:panelGroup>
		
		<h:panelGrid columns="2">

			<p:outputLabel id="nomeEdcLbl" style="font-weight: bold;" 
				for="nomeEdc" value="#{locale['blog.label.nome']}" />
			<p:inputText id="nomeEdc" value="#{AdminBlogBean.blog.nome}"
				label="#{locale['blog.label.nome']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
			</p:inputText>
			
			<p:outputLabel id="tituloEdcLbl" style="font-weight: bold;" 
				for="tituloEdc" value="#{locale['blog.label.titulo']}" />
			<p:inputText id="tituloEdc" value="#{AdminBlogBean.blog.titulo}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
			</p:inputText>
			
			<p:outputLabel id="descricaoEdcLbl" style="font-weight: bold;" 
				for="descricaoEdc" value="#{locale['blog.label.descricao']}" />
			<p:inputTextarea id="descricaoEdc" value="#{AdminBlogBean.blog.descricao}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
				counter="contadorDescricao"
				maxlength="255"
				required="true" />			
				
			<p:spacer />
			<h:panelGroup layout="block" 
				style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">
				<h:outputText id="contadorDescricao" />
			</h:panelGroup>		
			
			<p:outputLabel id="assuntosEdcLbl" style="font-weight: bold;" 
				for="assuntosEdc" value="#{locale['blog.label.assuntos']}" />
			<p:inputTextarea id="assuntosEdc" value="#{AdminBlogBean.blog.assuntos}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
				counter="contadorAssuntos"
				maxlength="255"
				required="true" />			
				
			<p:spacer />
			<h:panelGroup layout="block" 
				style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">			
				<h:outputText id="contadorAssuntos" />
			</h:panelGroup>
						
		</h:panelGrid>
		
		<h:panelGroup layout="block" 
			style="text-align: right; margin-top: 10px; border-top: dotted 1px; padding-top: 10px;">
			
			<p:commandButton id="salvarEdc" value="#{locale['crud.botao.salvar']}"
				icon="ui-icon-disk"
				styleClass="ui-priority-primary left"
				action="#{AdminBlogBean.salvarEdicao()}"
				update="edicaoBlogForm" />
					
			<p:commandButton id="cancelarEdc" value="#{locale['crud.botao.fechar']}"
				icon="ui-icon-close"
				action="#{AdminBlogBean.cancelarEdicao()}"
				update="edicaoBlogForm" />
							
		</h:panelGroup>
		
	</h:form>
	
</p:dialog>

<comps:confirmacao
	tituloDialogo="#{locale['crud.alteracoes.titulo']}"
	widgetVar="confirmaAlteracoesEdicaoBlogDlg"
	simAction="#{AdminBlogBean.salvarEdicaoConfirmar()}"
	naoAction="#{AdminBlogBean.salvarEdicaoCancelar()}"
	simUpdate=":tabView:listagemBlogForm :indexGrowl" 
	naoUpdate=""
	scriptOnComplete="confirmaAlteracoesEdicaoBlogDlg.hide()">
	
	<f:facet name="mensagemDialogo">
	
		<h:outputFormat value="#{locale['crud.alteracoes.pergunta.edicao']}">
			<f:param value="#{locale['blog.titulo']}" />
		</h:outputFormat>	
			
	</f:facet>
	
</comps:confirmacao>

<comps:confirmacao tituloDialogo="#{locale['crud.excluir.titulo']}"
	widgetVar="confirmaExclusaoBlogDlg"
	simAction="#{AdminBlogBean.excluirConfirmar()}"
	naoAction="#{AdminBlogBean.excluirCancelar()}"
	simUpdate=":tabView:listagemBlogForm :indexGrowl" 
	naoUpdate=":indexGrowl"
	scriptOnComplete="confirmaExclusaoBlogDlg.hide()">
	
	<f:facet name="mensagemDialogo">
	
		<h:outputFormat id="registroExclusao" value="#{locale['crud.excluir.pergunta']}">
			<f:param value="#{locale['blog']}" />
		</h:outputFormat>
		
	</f:facet>
		
</comps:confirmacao>
	
</ui:composition>